package com.atguigu.yygh.hosp.controller;


import com.atguigu.yygh.common.result.Result;
import com.atguigu.yygh.hosp.service.HospitalService;
import com.atguigu.yygh.model.hosp.Hospital;
import com.atguigu.yygh.vo.hosp.HospitalQueryVo;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Page;
import org.springframework.web.bind.annotation.*;

import java.util.Map;

@Api(tags = "医院接口")
@RestController
@RequestMapping("/admin/hosp/hospital")
//@CrossOrigin
public class HospitalController {

    @Autowired
    private HospitalService hospitalService;

    @ApiOperation("获取分页列表")
    @GetMapping("/findHospPage/{page}/{limit}")
    public Result findHospPage(@PathVariable Integer page
                            , @PathVariable Integer limit
                            , HospitalQueryVo hospitalQueryVo) {
        Page<Hospital> pages = hospitalService.findPage(page, limit, hospitalQueryVo);
        return Result.ok().data("pages", pages);
    }

    @ApiOperation("更新医院状态")
    @GetMapping("/updateStatus/{id}/{status}")
    public Result updateStatus(@PathVariable String id,
                               @PathVariable Integer status) {
        hospitalService.updateStatus(id,status);
        return Result.ok();
    }

    @ApiOperation("医院详情")
    @GetMapping("/show/{id}")
    public Result show (@PathVariable String id) {

       Map<String, Object> map = hospitalService.show(id);
       return Result.ok().data(map);
    }
}
